#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <QMutex>
#include "v4l2.h"
#include "yolo11.h"
#include <QPainter>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();


private slots:
    void captureAndDisplayFrame();
    void snapshot();
    void startRecording();
    void stopRecording();
    void startStreaming();
    void stopStreaming();
    void startYolo();
    void stopYolo();
    
private:
    void updateButtonStates();
    void processYoloInference(uint8_t* frame_data, QImage& image); // YOLO 推理和绘制

    Ui::MainWindow *ui;
    QTimer *timer;
    QMutex mutex;
    V4L2Context v4l2_ctx;
    bool isRecording = false;
    bool isStreaming = false;
    bool isYoloRunning = false;
    int frameCount = 0;

    // YOLO 相关
    rknn_app_context_t rknn_app_ctx; // YOLOv11 上下文
    bool yolo_initialized = false;
};
#endif // MAINWINDOW_H
